#include <bits/stdc++.h>
using namespace std;
long long  t,n,m,L,V,p[100005],ans,cnt;
long long maxn,sum[1000005],minn;
double dis;
bool flag1=true,flag2=true,flag3=true,tmp[25],vis[25];
vector <long long> v[25];
struct car{
    long long d,v,a;
}c[100005];
void dfs(long long step,long long sum){
    if (sum>minn) return;
    //cout<<sum<<"\n";
    if (step==m+1){
        memset(vis,0,sizeof(vis));
        for (int i=1;i<=m;i++){
            if (!tmp[i]) continue;
            for (int j=0;j<v[i].size();j++) vis[v[i][j]]=1;
        }
        int cnt=0;
        for (int i=1;i<=n;i++){
            if (vis[i]) cnt++;
        }
        //cout<<cnt<<' '<<sum<<"\n";
        if (cnt==ans) minn=min(minn,sum);
        return;
    }
    tmp[step]=1;
    dfs(step+1,sum+1);
    tmp[step]=0;
    dfs(step+1,sum);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
    while (t--){
        cin>>n>>m>>L>>V;
        ans=0,maxn=0;
        memset(sum,0,sizeof(sum));
        for (int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            if (c[i].a>0) flag2=flag3=false;
            else if (c[i].a==0) flag1=flag3=false;
            else flag1=flag2=false;
        }
        for (int i=1;i<=m;i++){
            cin>>p[i];
            maxn=max(maxn,p[i]);
            sum[p[i]]++;
        }
        for (int i=1;i<=L;i++) sum[i]=sum[i-1]+sum[i];
        if (flag2){
            for (int i=1;i<=n;i++){
                if (c[i].v>V && c[i].d<=maxn) ans++;
            }
            cout<<ans<<' ';
            if (ans) cout<<m-1<<"\n";
            else cout<<m<<"\n";
        }
        else if (flag1){
            for (int i=1;i<=n;i++){
                //cout<<((maxn-c[i].d)*2*c[i].a)<<' '<<V*V-c[i].v*c[i].v<<"\n";
                if (((maxn-c[i].d)*2*c[i].a)>V*V-c[i].v*c[i].v && c[i].d<=maxn) ans++;
                //else cout<<"\n"<<"\n"<<++cnt;
            }
            cout<<ans<<' ';
            if (ans) cout<<m-1<<"\n";
            else cout<<m<<"\n";
        }
        else if (flag3){
            for (int i=1;i<=n;i++){
                dis=(V*V-c[i].v*c[i].v)/(c[i].a*2.0);
                if (c[i].v>V && sum[(int)floor(dis)]-sum[c[i].d]>0) ans++;
            }
            cout<<ans<<' ';
            if (ans) cout<<m-1<<"\n";
            else cout<<m<<"\n";
        }
        else{
            for (int i=1;i<=n;i++){
                if (c[i].a>0){
                    dis=(V*V-c[i].v*c[i].v)/(c[i].a*2.0);
                    bool flag=false;
                    for (int j=1;j<=m;j++){
                        if (((p[j]-c[i].d)*2*c[i].a)>V*V-c[i].v*c[i].v && c[i].d<=p[j]){
                            flag=true;
                            v[j].push_back(i);
                        }
                    }
                    if (flag) ans++;
                }
                else if (c[i].a==0){
                    bool flag=false;
                    for (int j=1;j<=m;j++){
                        if (p[j]>=c[i].d && c[i].v>V){
                            flag=true;
                            v[j].push_back(i);
                        }
                    }
                    if (flag) ans++;
                }
                else{
                    dis=(V*V-c[i].v*c[i].v)/(c[i].a*2.0);
                    bool flag=false;
                    for (int j=1;j<=m;j++){
                        if (p[j]>=c[i].d && ((p[j]-c[i].d)*2*c[i].a)>V*V-c[i].v*c[i].v){
                            flag=true;
                            v[j].push_back(i);
                        }
                    }
                    if (flag) ans++;
                }
            }
            cout<<ans<<' ';
            minn=LONG_LONG_MAX;
            dfs(1,0);
            cout<<n-minn<<"\n";
        }
    }
    return 0;
}
